home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / initscripts.preinst < prev    next >
Text File  |  2008-10-14  |  3KB  |  92 lines

  1. #! /bin/sh
  2. #
  3. # initscripts preinst
  4. #
  5.  
  6.  
  7. # Remove a no-longer used conffile
  8. #
  9. # $1: conffile
  10. #
  11. # If the argument was not listed as a conffile, silently do nothing.
  12. # Adapted from code obtained from http://wiki.debian.org/DpkgConffileHandling
  13. eliminate_conffile() {
  14.     PKGNAME="initscripts"
  15.     CONFFILE="$1"
  16.  
  17.     if [ -e "$CONFFILE" ]; then
  18.         CURRENT_MD5SUM="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  19.         FACTORY_MD5SUM="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
  20.         if [ "$CURRENT_MD5SUM" != "$FACTORY_MD5SUM" ]; then
  21.             echo "Obsolete conffile $CONFFILE has been modified by you."
  22.             echo "Saving as $CONFFILE.dpkg-old ..."
  23.             mv -f "$CONFFILE" "$CONFFILE".dpkg-old
  24.         else
  25.             echo "Removing unmodified and obsolete conffile $CONFFILE ..."
  26.             rm -f "$CONFFILE"
  27.         fi
  28.     fi
  29. }
  30.  
  31. # Compares a file to the "factory md5sum", and if it matches, removes it.
  32. # This is useful for when converting from to a conffile *and* changing its contents
  33. # at the same time.
  34. convert_to_conffile() {
  35.     CONFFILE="$1"
  36.     FACTORY_MD5SUM="$2"
  37.  
  38.     if [ -e "$CONFFILE" ]; then
  39.         CURRENT_MD5SUM="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  40.         if [ "$CURRENT_MD5SUM" = "$FACTORY_MD5SUM" ]; then
  41.             rm -f "$CONFFILE"
  42.         fi
  43.     fi
  44. }
  45.  
  46. case "$1" in
  47.   install|upgrade)
  48.     #
  49.     # /etc/init.d/stop-bootlogd used to be a symlink to bootlogd;
  50.     # now it is a separate script.  We need to remove the symlink here,
  51.     # before dpkg installs the /etc/init.d/stop-bootlogd file.
  52.     #
  53.     [ -L /etc/init.d/stop-bootlogd ] && rm -f /etc/init.d/stop-bootlogd
  54.     #
  55.     # Remove obsolete conffiles
  56.     #
  57.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-10" ; then
  58.         eliminate_conffile "/etc/init.d/bootclean.sh"
  59.     fi
  60.     #
  61.     # The /etc/init.d/bootclean script fragment was moved to
  62.     # /lib/init/ in version 2.86.ds1-39
  63.     #
  64.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-54" ; then
  65.         eliminate_conffile "/etc/init.d/bootclean"
  66.     fi
  67.     #
  68.     # The /etc/init.d/waitnfs.sh script was replaced by mountnfs.sh
  69.     #
  70.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-56ubuntu1" ; then
  71.         eliminate_conffile "/etc/init.d/waitnfs.sh"
  72.     fi
  73.     #
  74.     # The /etc/init.d/rc.local was made a conffile in 2.86.ds1-18, which for Ubuntu
  75.     # translates into "on upgrades to Intrepid and onwards". The only valid upgrade
  76.     # path to Intrepid is from Hardy, so we just check against the md5sum from there.
  77.     #
  78.     if [ "$2" ] && dpkg --compare-versions "$2" lt "2.86.ds1-18" ; then
  79.         convert_to_conffile "/etc/init.d/rc.local" e3756487011471f7753d5d94ce4b6af4
  80.     fi
  81.     #
  82.     # Move conflicting log _file_ if present
  83.     #
  84.     [ -f /var/log/fsck ] && mv -f /var/log/fsck /var/log/fsck.dpkg-old
  85.     ;;
  86.   abort-upgrade)
  87.     exit 0
  88.     ;;
  89. esac
  90.  
  91. :
  92.